import os
import requests

def left_rfc():
    folder_path = '/Users/xx/Desktop/RFC'  # 替换为您的文件夹路径

    target_size = 986  # 目标文件大小（字节）

    lst = []

    for filename in os.listdir(folder_path):
        file_path = os.path.join(folder_path, filename)
        if os.path.isfile(file_path) and os.path.getsize(file_path) == target_size:
            name, ext = os.path.splitext(filename)
            lst.append(name)

    return lst



def download_pdf(url, save_path):
    response = requests.get(url)
    with open(save_path, 'wb') as f:
        f.write(response.content)

count = 8052

for num in range(1, count):
    num = count - num
    # url = 'https://www.rfc-editor.org/rfc/rfc{}.pdf'.format(num)
    url = 'https://www.rfc-editor.org/rfc/pdfrfc/rfc{}.txt.pdf'.format(num)
    save_path = 'rfc{}.pdf'.format(num)
    download_pdf(url, save_path)
    print(num)